Nil, Cons, Stream and Singleton

The simplest list is Nil, the empty list which we have been writing [  ].

#math122#
Nil = Second  

The other possible list is Cons~x~xs, which has head x and tail xs.
#math123#
Cons~x~xs~f~e = f~x~xs  

Every list can be constructed using these functions. The list [1, 2, 3] is #math124#Cons~1~(Cons~2~(Cons~3~Nil )), and the list #math125#[a, a, a,…] is Stream~a where Stream is defined:
#math126#
Stream~a = Cons~a~(Stream~a)  

There's even at least one application for infinite lists, as we'll see in Section~#outputroutines#241>.

The singleton list [a] is #math127#Singleton~a, defined as:

#math128#
Singleton~a = Cons~a~Nil  

These all have straightforward TEX definitions. =TeXcode